<?php
$GLOBALS['Md'] = "RHUSJW24";
$GLOBALS['Pd'] = "B";
require_once($_SERVER['DOCUMENT_ROOT']."/defaultconf.mex");
MYTCONN();

	//=======================================================
	// Gest Users
	
	if(!isset($_POST['it_status'])){$_POST['it_status']=1;}
		
	$GET = $GLOBALS['MYT']->db_array("SELECT
				ref AS ref,
				main_users_ref AS user,
				main_office_ref AS balcao,
				DATE(data) AS data,
				estado AS estado,
				problema AS problema,
				prioridade AS prioridade,
				Data_Reso as data_reso,
				smb_Name as atribuido_a,
				obs as obs
				FROM systemoffice.it_requests
				LEFT OUTER JOIN systemoffice.staff_members ON smb_ID = atribuido_a WHERE estado = '{$_POST['it_status']}'
		ORDER BY estado, data, balcao");
				
	$CARD = $GET[0];
	
	$UltimoDia = '';
	$UltimoEstado = '';
	$ultimoBalcao = '';	

	
?>
<div class="title">Ticket Reports</div>
<table>
<?php
	for($i=1;$i<=$GET[0];$i++){

		if($UltimoDia!=$GET[$i]['data']){
			echo '<tr><td>'.$GET[$i]['data'].'</td></tr>';
			$UltimoDia = $GET[$i]['data'];

		}		
		if($UltimoEstado!=$GET[$i]['estado']){
			echo '<tr><td>'.$GET[$i]['estado'].'</td></tr>';
			$UltimoEstado = $GET[$i]['estado'];

		}	
		if($UltimoBalcao!=$GET[$i]['balcao']){
			echo '<tr><td>'.$GET[$i]['balcao'].'</td></tr>';
			$UltimoBalcao = $GET[$i]['balcao'];

		}
	echo '<tr><td>'.$GET[$i]['problema'].'</td></tr>';	
	}
?></table>